/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2024-03-28 15:03:37
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-06-27 15:14:17
 * @FilePath: \project\node-project\server\util\JWT.js
 * @Description: 
 */
const jwt = require('jsonwebtoken');
const secret = 'scret_data';

const JWT = {
    generate(data, expiresIn = '1d') {
        return jwt.sign(data, secret, {expiresIn});
    },
    verify(token) {
        try {
            return jwt.verify(token, secret); 
        } catch (error) {
            console.log('time out:', error)
        }
        
    }
}

module.exports = JWT;